package com.linewell.controller;

import com.linewell.service.IPointService;
import com.linewell.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Title: ssm2
 * @description:点赞收藏管理控制器
 * @author: hyuhuang@linewell.com
 * @since:2018/2/13
 */
@Controller
public class PointController {

    @Autowired
    IPointService pointService;
    /**
     * @descripition 是否点赞
     * @author hyuhuang@linewell.com
     * @date 2018/2/27 10:52
     * @param pointId, userId
     * @return com.linewell.utils.Msg
     */
    @RequestMapping("/isFavor")
    @ResponseBody
    public Msg isFavor(@RequestParam("pointId") Long pointId, @RequestParam("userId") Long userId){
        return pointService.checkIsFavor(userId,pointId);
    }
    /**
     * @descripition  更新赞的数量
     * @author hyuhuang@linewell.com
     * @date 2018/2/27 10:52
     * @param userId, pointId, isFavorType, zanNum, caiNum
     * @return com.linewell.utils.Msg
     */
    @RequestMapping("/updatePoint")
    @ResponseBody
    public Msg updatePoint(@RequestParam("userId") Long userId,@RequestParam("pointId") Long pointId,
                           @RequestParam("dzType") int isFavorType,@RequestParam("zanNum") int zanNum,
                           @RequestParam("caiNum") int caiNum){
        return pointService.updatePoint(userId,pointId,isFavorType,zanNum,caiNum);
    }
    /**
     * @descripition 更新收藏的数量
     * @author hyuhuang@linewell.com
     * @date 2018/2/27 10:53
     * @param userId, pointId, isCollectType, collectNum
     * @return com.linewell.utils.Msg
     */
    @RequestMapping("/updateCollect")
    @ResponseBody
    public Msg updateCollect(@RequestParam("userId") Long userId,@RequestParam("pointId") Long pointId,
                           @RequestParam("dzType") int isCollectType,@RequestParam("collectNum") int collectNum){
        return pointService.updateCollect(userId,pointId,isCollectType,collectNum);
    }
    /**
     * @descripition 是否收藏
     * @author hyuhuang@linewell.com
     * @date 2018/2/27 10:53
     * @param pointId, userId
     * @return com.linewell.utils.Msg
     */
    @RequestMapping("/isCollect")
    @ResponseBody
    public Msg isCollect(@RequestParam("pointId") Long pointId, @RequestParam("userId") Long userId){
        System.out.println(pointId + "|" + userId);
        return pointService.checkIsCollect(userId,pointId);
    }
    /**
     * @descripition  判断是否评论点赞
     * @author hyuhuang@linewell.com
     * @date 2018/3/23 22:17
     * @param replyId, userId
     * @return com.linewell.utils.Msg
     */
    @RequestMapping("/isCommentFavor")
    @ResponseBody
    public Msg isCommentFavor(@RequestParam("replyId") Long replyId,@RequestParam("userId") Long userId){
        return pointService.checkIsCommentFavor(replyId,userId);
    }
    /** 更新评论信息
     * @descripition
     * @author hyuhuang@linewell.com
     * @date 2018/5/5
     * @param replyIduserIdisFavorTypezanNumcaiNum
     * @return com.linewell.utils.Msg
     */
    @RequestMapping("/updateCommentPoint")
    @ResponseBody
    public Msg updateCommentPoint(@RequestParam("replyId") Long replyId,@RequestParam("userId") Long userId,
                           @RequestParam("dzType") int isFavorType,@RequestParam("zanNum") int zanNum,
                           @RequestParam("caiNum") int caiNum){
        return pointService.updateCommentPoint(replyId,userId,isFavorType,zanNum,caiNum);
    }
}
